module Maze
  class Orthogonal < Generic
    OPPOSITE = { N => S, S => N, E => W, W => E }

    def random_directions
      [N, S, E, W].sort_by { rand }
    end

    alias_method :directions, :random_directions

    def opposite(direction)
      OPPOSITE[direction]
    end

    def calculate_offset_x_axis(*args)
      distance_x = { N => 0, S => 0, E => 1, W => -1 }
      distance_x[args.first]
    end

    def calculate_offset_y_axis(*args)
      distance_y = { N => -1, S => 1, E => 0, W => 0 }
      distance_y[args.first]
    end
  end
end
